Repository navigation
feat(search): support qualified symbol matching in workspace.rankNames and workspace.symbolQuery - #255
Conversation
…s and workspace.symbolQuery
| let path = candidate.path.as_deref()?; | ||
| let normalized = qualifier.replace("::", "/").replace('.', "/"); | ||
| let path_hit = match_name(&normalized, path).or_else(|| match_name(qualifier, path))?; |
There was a problem hiding this comment.
🟡 Missing qualified symbols on Windows
match_qualified drops valid symbols with short container names when their package is supplied by a backslash-separated Windows path. match_container and the path fallback both look for forward slashes in that path.
Learn more
The rankNames contract accepts full candidate paths and lets them supply a symbol's qualifier. The text matcher only compares characters case-insensitively; it does not equate the two slash characters (match_fragments). With an LSP container that only identifies the class, the package check needs to match the package prefix against the path. Both that check and the full qualifier fallback compare a forward-slash pattern against the original path.
Example: Query com.example.UserService.getUser with a candidate named getUser, container UserService, and path C:\repo\src\com\example\UserService.java. This is dropped, while the same candidate with forward slashes matches.
Recommended fix: Use lithe_platform::paths::slash_separated with the relevant Platform for the path used by both qualified comparisons. Keep the original path for open/recent identity. Test the existing dotted-package fixture with native Windows separators.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let (prefix, tail) = split_qualified_symbol(qualifier)?; | ||
| let tail_hit = match_name(tail, container)?; | ||
| if let Some(path) = path { | ||
| let normalized_prefix = prefix.replace("::", "/").replace('.', "/"); | ||
| if match_name(&normalized_prefix, path).is_none() { | ||
| return None; | ||
| } | ||
| } | ||
| Some((tail_hit.degree / (PATH_DEGREE_DIVISOR * 2)).max(1)) |
There was a problem hiding this comment.
🟡 Unverified packages in symbol results
When a candidate lacks a path, match_container accepts a class-name match without verifying the requested package. Methods from unrelated packages then appear under the same qualified query.
Learn more
The rankNames contract allows candidates without a path, but a qualified search still needs evidence for the whole qualifier. When a container does not match the whole qualifier, the fallback can combine the class from the container with the package from the path. Without a path, it currently returns the class-only match even though nothing establishes the package.
Example: Search for com.example.UserService.getUser with a candidate { "name": "getUser", "container": "UserService" } from org.other. It is returned despite having no matching package evidence.
Recommended fix: Require a matching path prefix for this fallback. Leave the full-container match available without a path.
| let (prefix, tail) = split_qualified_symbol(qualifier)?; | |
| let tail_hit = match_name(tail, container)?; | |
| if let Some(path) = path { | |
| let normalized_prefix = prefix.replace("::", "/").replace('.', "/"); | |
| if match_name(&normalized_prefix, path).is_none() { | |
| return None; | |
| } | |
| } | |
| Some((tail_hit.degree / (PATH_DEGREE_DIVISOR * 2)).max(1)) | |
| let (prefix, tail) = split_qualified_symbol(qualifier)?; | |
| let tail_hit = match_name(tail, container)?; | |
| let path = path?; | |
| let normalized_prefix = prefix.replace("::", "/").replace('.', "/"); | |
| match_name(&normalized_prefix, path)?; | |
| Some((tail_hit.degree / (PATH_DEGREE_DIVISOR * 2)).max(1)) |
Was this helpful? React with 👍 or 👎 to provide feedback.
| } else if let Some((qualifier, member)) = qualified { | ||
| if let Some(hit) = match_qualified(qualifier, member, candidate) { | ||
| hit | ||
| } else if let Some(hit) = candidate | ||
| .path | ||
| .as_deref() | ||
| .and_then(|path| match_name(query, path)) | ||
| { | ||
| ((hit.degree / PATH_DEGREE_DIVISOR).max(1), Vec::new()) | ||
| } else { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
🟡 File paths admit unrelated symbols
For qualified queries, rank_names_command returns symbols whose paths match the full query even when their names fail the member match. Unrelated symbols from those files appear in the results.
Learn more
The rankNames contract allows hosts to supply symbol or navigator lists. For a qualified query, the path can establish the qualifier but not the member. match_qualified rejects candidates whose symbol name fails the member match, but the caller then lets the path satisfy the whole query.
Example: A navigator list includes loadDefaults from src/config.read.ts. Searching for Config.read returns loadDefaults even though read does not match its name.
Recommended fix: Drop this path-only fallback for recognized qualified queries. Keep the direct name match for candidates whose names already include their qualifier and the existing path-only fallback for unqualified queries.
| } else if let Some((qualifier, member)) = qualified { | |
| if let Some(hit) = match_qualified(qualifier, member, candidate) { | |
| hit | |
| } else if let Some(hit) = candidate | |
| .path | |
| .as_deref() | |
| .and_then(|path| match_name(query, path)) | |
| { | |
| ((hit.degree / PATH_DEGREE_DIVISOR).max(1), Vec::new()) | |
| } else { | |
| continue; | |
| } | |
| } else if let Some((qualifier, member)) = qualified { | |
| let Some(hit) = match_qualified(qualifier, member, candidate) else { | |
| continue; | |
| }; | |
| hit |
Was this helpful? React with 👍 or 👎 to provide feedback.
* feat(tree): 项目树与提交文件树支持紧凑显示单一子文件夹链
- workspace.projectTree.rows 新增可选 compact:已列出、只含一个子文件夹的非根文件夹与子文件夹合成一行(同 IDEA/VS Code),返回 heads 给出每行链首;选区与 top 落在链中文件夹时移到该行。
- git.changedFileGroups 新增可选 nest{compact}:按树列出全部上级文件夹并给出 depth 与 label,compact 时把无文件且只含一个文件夹的链合并,label 用 / 连接。
- 两个 fixture 增加对应用例,rust-core-api.md 补充契约。
- 顺手修 name_ranking.rs 的 clippy question_mark(#255 引入)。
Refs 1lck/Lithe-IDEA#2641
* feat(tree): 紧凑项目树按行返回缩进层级 depths
紧凑链无论多长只占一层缩进;链下的文件和文件夹要跟着少缩进。workspace.projectTree.rows 在 compact 时多返回 depths,每行一个:节点 depth 减去它上面与唯一子文件夹合并的文件夹数。补一个链套链的 fixture。
Summary
split_qualified_symbolinrust/crates/project/src/name_matching.rsto splitClass.member,Class#member, andns::memberat the last separator.containeronRankCandidateand opt-inqualifiedSymbolsflag onRankNamesRequestinrust/crates/project/src/name_ranking.rs, matchingmemberagainstnameandqualifieragainstcontainerorpathwithout altering dotted filename ranking.workspace.symbolQuerycommand (rust/crates/core/src/protocol/command.rs,rust/crates/core/src/runtime/dispatcher/workspace.rs) so hosts share Core's query splitting rule when querying LSPworkspace/symbol.rust/contracts/rust-core-api.md,rust/fixtures/search/rank-names-v1.json, andrust/crates/core/src/tests/rank_names.rs.Verification
cargo fmt --all --manifest-path rust/Cargo.toml -- --checkpassed.cargo test --manifest-path rust/Cargo.toml -p lithe-core rank_namespassed (4 passed).